package async.thread;

import java.util.concurrent.*;

/**
 * @author : zhouliangliang5
 * @date : 2023/3/17 10:29
 * @description : 可以获取返回结果
 */
public class AsyncCallable implements Callable {
    @Override
    public Object call() throws Exception {
        return "asyncCallable";
    }

    public static void main(String[] args) throws Exception {
        AsyncCallable callable = new AsyncCallable();
        ExecutorService service = Executors.newSingleThreadExecutor();
        Future future = service.submit(callable);
        Object result = future.get(200, TimeUnit.MICROSECONDS);
        System.out.println(result);
    }
}
